import { computed } from 'vue'
import { useLoadMore  } from 'vue-request'

/**
 * 分页
 * @param {请求方法} requestApiMethod
 * @returns
 */
export default function (requestApiMethod) {
  // 分页查询数据
  const {
    data,
    loadingMore,
    dataList,
    loading,
    noMore,
    loadMore,
    refresh
  } = useLoadMore(requestApiMethod)

  // 数据表格的数据源
  const dataSource = computed(() => data.value?.data.dataList || [])


  return {
    dataSource,
    data, loadingMore, dataList, loading, noMore, loadMore, refresh
  }
}
